#include <iostream>

//lapacke headers

#include <lapacke.h>

extern lapack_int LAPACKE_dgesv(int matrix_order, lapack_int n, lapack_int nrhs,

                                double *a, lapack_int lda, lapack_int *ipiv,

                                double *b, lapack_int ldb);

int main()
{
    using namespace std;
    int N = 4;
    // double A[16] = {1, 2, 3, 1,

    //                 4, 2, 0, 2,

    //                 -2, 0, -1, 2,

    //                 3, 4, 2, -3};
    // double B[8] = {6, 2, 1, 8,

    //                1, 2, 3, 4};

    double A[16] = { 1,4, -2, 3,
     2, 2, 0, 4,
3, 0, -1, 2,
1, 2, 2, -3};
    double B[8] = {6,1,
2,	2,
1,	3,
8,	4
};
    int ipiv[4];
    int n = N;
    int nrhs = 2;
    int lda = 4;
    int ldb = 2;
    auto info = LAPACKE_dgesv(LAPACK_ROW_MAJOR, n, nrhs, A, lda, ipiv, B, ldb);
    cout<< "Info:"<<info<<'\n';
    if (info == 0)
    {
        int i = 0;
        int j = 0;
        for (j = 0; j < nrhs; j++)
        {
            cout<<"x"<<j<<'\n';
            for (i = 0; i < N; i++)
                cout<<B[i+j*N]<<"  ";
            cout<<'\n';
        }
    }
    return 0;
};